<HTML><FONT FACE=Arial, Verdana, Sans><TITLE>StandardTrader.agent</TITLE><BODY><STYLE TYPE="text/css"><!--.centeralign <BLOCKQUOTE>text-align:center</BLOCKQUOTE>--></STYLE><HEAD><P CLASS="centeralign">StandardTrader.agent</P></HEAD><IMG SRC=images/highfrequency.StandardTrader.png border=1 alt="Flowchart for StandardTrader.agent" title="Flowchart for StandardTrader.agent"></P>The package name is "highfrequency".</p>
The following external code is referenced:<BLOCKQUOTE></p>
<li>Components from java.io.*</li></p>
<li>Components from java.math.*</li></p>
<li>Components from java.util.*</li></p>
<li>Components from javax.measure.unit.*</li></p>
<li>Components from org.jscience.mathematics.number.*</li></p>
<li>Components from org.jscience.mathematics.vector.*</li></p>
<li>Components from org.jscience.physics.amount.*</li></p>
<li>Components from repast.simphony.adaptation.neural.*</li></p>
<li>Components from repast.simphony.adaptation.regression.*</li></p>
<li>Components from repast.simphony.context.*</li></p>
<li>Components from repast.simphony.context.space.continuous.*</li></p>
<li>Components from repast.simphony.context.space.gis.*</li></p>
<li>Components from repast.simphony.context.space.graph.*</li></p>
<li>Components from repast.simphony.context.space.grid.*</li></p>
<li>Components from repast.simphony.engine.environment.*</li></p>
<li>Components from repast.simphony.engine.schedule.*</li></p>
<li>Components from repast.simphony.engine.watcher.*</li></p>
<li>Components from repast.simphony.groovy.math.*</li></p>
<li>Components from repast.simphony.integration.*</li></p>
<li>Components from repast.simphony.matlab.link.*</li></p>
<li>Components from repast.simphony.query.*</li></p>
<li>Components from repast.simphony.query.space.continuous.*</li></p>
<li>Components from repast.simphony.query.space.gis.*</li></p>
<li>Components from repast.simphony.query.space.graph.*</li></p>
<li>Components from repast.simphony.query.space.grid.*</li></p>
<li>Components from repast.simphony.query.space.projection.*</li></p>
<li>Components from repast.simphony.parameter.*</li></p>
<li>Components from repast.simphony.random.*</li></p>
<li>Components from repast.simphony.space.continuous.*</li></p>
<li>Components from repast.simphony.space.gis.*</li></p>
<li>Components from repast.simphony.space.graph.*</li></p>
<li>Components from repast.simphony.space.grid.*</li></p>
<li>Components from repast.simphony.space.projection.*</li></p>
<li>Components from repast.simphony.ui.probe.*</li></p>
<li>Components from repast.simphony.util.*</li></p>
<li>Components from simphony.util.messages.*</li></p>
<li>Components from static java.lang.Math.*</li></p>
<li>Components from static repast.simphony.essentials.RepastEssentials.*</li></p>
</BLOCKQUOTE><P></p>
The class "StandardTrader" is defined with visibility "public" . This is an agent.</p>
 <BLOCKQUOTE></p>
</p>
    <li>There is a field named "buyPrice" with visibility "public" of type "double" and default value 0. This is the price at which the agent is willing to buy. The block is tagged with the name "Limit Buy Price".</li></p>
</p>
    <li>There is a field named "sellPrice" with visibility "public" of type "double" and default value 1000000. This is the price at which an agent is willing to sell. The block is tagged with the name "Limit Sell Price".</li></p>
</p>
    <li>There is a field named "eps" with visibility "public" of type "double" and default value 74.99. This is the 2010 estimated EPS for the S&P 500. The block is tagged with the name "S&P 500 Est 2010 EPS".</li></p>
</p>
    <li>There is a field named "symbol" with visibility "public" of type "String" and default value INDEXSP. This is the symbol of the security the agent is trading. The block is tagged with the name "Security Symbol".</li></p>
</p>
    <li>There is a field named "quantity" with visibility "public" of type "int" and default value 100. This is the default bid quantity, fixed at 100 shares. The block is tagged with the name "Bid Quantity".</li></p>
</p>
    </p>
    </p>
        <li>There is a method named "setBuyPrice" method has visibility     "public". Set Limit Buy Value The block is tagged with the name "Set Limit Buy Price".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The setBuyPrice method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 1d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "setBuyPrice" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         Calculate limit buy price as a multiple of S&P 500 EPS.</p>
        setBuyPrice(eps*(RandomHelper.getNormal().nextDouble(10.0,18.0)))</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "setSellPrice" method has visibility     "public". Set Limit Sell Value The block is tagged with the name "Set Limit Sell Price".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The setSellPrice method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 1d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "setSellPrice" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         Calculate limit sell price as so much above the limit buy price.</p>
        setSellPrice(buyPrice + RandomHelper.getNormal().nextDouble(1.0,5.0))</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "SubmitBid" method has visibility     "public" and parameters [highfrequency.OrderBook watchedAgent]. This is the step behavior. The block is tagged with the name "Bid If Price Is Right".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The SubmitBid method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 1d</li></p>
        <li>interval = 1d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
    <BLOCKQUOTE>The SubmitBid method will trigger as follows:<BLOCKQUOTE></p>
        <li>watcheeClassName = 'highfrequency.OrderBook'</li></p>
        <li>watcheeFieldNames = 'currentPrice'</li></p>
        <li>query = 'linked_from'</li></p>
        <li>triggerCondition = 'currentPrice < buyPrice'</li></p>
        <li>whenToTrigger = WatcherTriggerSchedule.LATER</li></p>
        <li>scheduleTriggerDelta = 1d</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "SubmitBid" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        Bid(symbol, agentID, quantity)</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "SubmitSell" method has visibility     "public" and parameters [highfrequency.OrderBook watchedAgent]. This is the step behavior. The block is tagged with the name "Sell If Price Is Right".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The SubmitSell method will trigger as follows:<BLOCKQUOTE></p>
        <li>watcheeClassName = 'highfrequency.OrderBook'</li></p>
        <li>watcheeFieldNames = 'currentPrice'</li></p>
        <li>query = 'linked_from'</li></p>
        <li>triggerCondition = 'currentPrice > sellPrice'</li></p>
        <li>whenToTrigger = WatcherTriggerSchedule.LATER</li></p>
        <li>scheduleTriggerDelta = 1d</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "SubmitSell" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        Ask(symbol, agentID, quantity)</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
</p>
</BLOCKQUOTE></p>
</p>
</BODY></HTML>